import { defineStore } from 'pinia';
import { wish } from '@/services/apis';

export const useWishStore = defineStore('wish', {
    state: () => ({
        wishList: []
    }),
    actions: {
        async add(params: any) {
            await wish.add(params);
            this.list()
        },
        async list() {
            try {
                const pageSize = 16;
                const pageNum = 1;
                const isAsc = 'desc'
                this.wishList = await wish.list({ pageSize, pageNum, isAsc});
            } catch (error) {
                return []
            }
        },
        async edit(params: any) {
            return await wish.edit(params);
        },
        async userWish(params: any) {
            return await wish.userWish(params);
        },
        async delete(params: any) {
            return await wish.delete(params);
        }
    }
})